const csr = @import("riscv").csr;
const root = @import("kernel.zig");
const task = @import("task.zig");

const print = root.print;

pub const Sysnum = enum(u8) {
    gethartid,
};

pub fn call(ctx: *task.Context) void {
    const sysnum: Sysnum = @enumFromInt(ctx.a7);
    switch (sysnum) {
        .gethartid => ctx.a0 = gethartid(@ptrFromInt(ctx.a0)),
    }
}

fn gethartid(id: *usize) usize {
    print("--> sys_gethid, arg0 = 0x{x}\n", .{@intFromPtr(id)});
    id.* = csr.mhartid.read();
    return 0;
}
